﻿Public Class DayNightCheck

    Private szDay As String = ""
    Private szNight As String = ""

    Public Event Selected(ByVal sender As Object, ByVal e As DncEventArgs)

    Public Enum DayNight
        Day
        Night
    End Enum

    Public Enum Result
        OK
        Slash
    End Enum

    Public ReadOnly Property Day As String
        Get
            Return szDay
        End Get
    End Property

    Public ReadOnly Property Night As String
        Get
            Return szNight
        End Get
    End Property

    Private Sub btnDayOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDayOK.Click
        szDay = OK
        Dim btn As Button = CType(sender, Button)
        btn.BackColor = Color.Lime
        btnDaySlash.BackColor = Drawing.SystemColors.Control
        btnDaySlash.UseVisualStyleBackColor = True
        RaiseEvent Selected(Me, New DncEventArgs(DayNight.Day, Result.OK))
    End Sub

    Private Sub btnDaySlash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDaySlash.Click
        szDay = "/"
        Dim btn As Button = CType(sender, Button)
        btn.BackColor = Color.Lime
        btnDayOK.BackColor = Drawing.SystemColors.Control
        btnDayOK.UseVisualStyleBackColor = True
        RaiseEvent Selected(Me, New DncEventArgs(DayNight.Day, Result.Slash))
    End Sub

    Private Sub btnNightOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNightOK.Click
        szNight = OK
        Dim btn As Button = CType(sender, Button)
        btn.BackColor = Color.Lime
        btnNightSlash.BackColor = Drawing.SystemColors.Control
        btnNightSlash.UseVisualStyleBackColor = True
        RaiseEvent Selected(Me, New DncEventArgs(DayNight.Night, Result.OK))
    End Sub

    Private Sub btnNightSlash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNightSlash.Click
        szNight = "/"
        Dim btn As Button = CType(sender, Button)
        btn.BackColor = Color.Lime
        btnNightOK.BackColor = Drawing.SystemColors.Control
        btnNightOK.UseVisualStyleBackColor = True
        RaiseEvent Selected(Me, New DncEventArgs(DayNight.Night, Result.Slash))
    End Sub

    Public Sub SetButon(ByVal dn As DayNight, ByVal rslt As Result)
        If dn = DayNight.Day Then
            If rslt = Result.OK Then
                btnDayOK_Click(btnDayOK, New EventArgs)
            ElseIf rslt = Result.Slash Then
                btnDaySlash_Click(btnDaySlash, New EventArgs)
            End If
        ElseIf dn = DayNight.Night Then
            If rslt = Result.OK Then
                btnNightOK_Click(btnNightOK, New EventArgs)
            ElseIf rslt = Result.Slash Then
                btnNightSlash_Click(btnNightSlash, New EventArgs)
            End If
        End If
    End Sub

    Public Sub Clear()
        szDay = String.Empty
        szNight = String.Empty
        btnDaySlash.BackColor = Drawing.SystemColors.Control
        btnDaySlash.UseVisualStyleBackColor = True
        btnDayOK.BackColor = Drawing.SystemColors.Control
        btnDayOK.UseVisualStyleBackColor = True
        btnNightSlash.BackColor = Drawing.SystemColors.Control
        btnNightSlash.UseVisualStyleBackColor = True
        btnNightOK.BackColor = Drawing.SystemColors.Control
        btnNightOK.UseVisualStyleBackColor = True
    End Sub
End Class

Public Class DncEventArgs
    Inherits EventArgs

    Public DayNight As DayNightCheck.DayNight
    Public Result As DayNightCheck.Result

    Public Sub New(ByVal dn As DayNightCheck.DayNight, ByVal rslt As DayNightCheck.Result)
        DayNight = dn
        Result = rslt
    End Sub
End Class
